#ifndef MARSEXPLORER_HEURISTIC_H
#define MARSEXPLORER_HEURISTIC_H

#include <map>
#include <queue>
#include "regex.h"
#include "../../heuristic.h"

using namespace std;

/** element comparison operator for priority queue */
class mycomparison
{
public:
    mycomparison() {;}
    bool operator() (pair< int, pair<int, int> >& lhs, pair< int, pair<int, int> >&rhs) const
    {
        /** reverse order because STL PQs order descending, yet Dijkstra requires ascending order */
        return (lhs.first > rhs.first);
    }
};

class MarsExplorerHeuristic : public Heuristic {
    bool initialized;
    int min_operator_cost;
    map<string,regex_t> RE;
    vector< vector<int> > mymap;
    vector< vector<int> > dist_from_mothership;
    pair<int, int> dijkstra_target;
    priority_queue< pair< int, pair<int, int> >, vector< pair< int, pair<int, int> > >, mycomparison > dijkstra_pq;
protected:
    virtual void initialize();
    virtual int compute_heuristic(const State &state);
    virtual void mark_move_operator(int agent_index, bool laden, int agent_x, int agent_y, int target_x, int target_y);
    virtual void mark_operator(char *opstr);
    virtual void read_map();
    virtual void prettyprint_map();
    virtual void dijkstra_move(int startx, int starty, int targetx, int targety, bool laden);
    virtual void dijkstra(vector< vector<int> > *themap);
    virtual void dijkstra_pushnewneighbor(int x, int y, int dist, vector< vector<int> > *themap);
public:
    MarsExplorerHeuristic(const Options &options);
    ~MarsExplorerHeuristic();
};



#endif
